<!DOCTYPE html>

<html lang="en">
<head>
    <title>DCEP后台管理系统</title>

    <!--引入layui-->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" >
    <link href="/iconfont/style.css" type="text/css" rel="stylesheet">
    <link  type="text/css" rel="stylesheet" href="/css/login.css" >
    <link rel="prerender" href="http://yujiangshui.com/" />
    <style>
        .user-info-head{
            width: 50px;
            height: 50px;
            line-height: 110px;

            border: 2px solid #eee;
            border-radius: 50%;
            overflow: hidden;
            cursor: pointer;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<div class="container wrap1" style="height:450px;width: 450px;">
    <h2 class="mg-b20 text-center colorWrite">后台管理系统</h2>
    <div class="col-sm-8 col-md-5 center-auto pd-sm-50 pd-xs-20 main_content">
        <p class="text-center font16 colorWrite">用户注册</p>
        <form class="layui-form" autocomplete="off">
            <div class="form-group mg-t20">
                <i class="icon-user icon_font"></i>
                <input type="text" class="login_input colorWrite layui-input" lay-verify="username" name="userName" id="userName"
                       autocomplete="off"
                       placeholder="请输入用户名"/>
            </div>
            <div class="form-group mg-t20">
                <i class="icon-lock icon_font"></i>
                <input type="password" style="display:none;width:0;height:0;">
                <input type="password" class="login_input colorWrite layui-input" lay-verify="password" autocomplete="new-password"
                       name="password"
                       id="password"
                       placeholder="请输入密码"/>
            </div>
            <div class="form-group mg-t20">
                <i class="icon-lock icon_font"></i>
                <input type="password" style="display:none;width:0;height:0;">
                <input type="password" class="login_input colorWrite layui-input" lay-verify="repass" autocomplete="new-password"
                       name="repass"
                       id="repass"
                       placeholder="请输入密码"/>
            </div>
<!--            <%--  Shiro的记住我功能并不安全，所以这里没有特殊需求先不采用记住我功能 --%>-->
<!--            <%--<div class="layui-form-item">--%>-->
<!--            <%--<input type="checkbox" name="rememberMe" lay-skin="switch" value="1" lay-text="记住我" checked>--%>-->
<!--            <%--</div>--%>-->
            <div class="layui-form-item mg-t20">
                <input type="checkbox" name="agreement" lay-skin="primary" title="同意用户协议" checked>
            </div>
            <div class="layui-form-item mg-t20">
                <button lay-submit lay-filter="relogin" class="login_btn layui-btn">注册</button>
            </div>
            <div class="layui-trans">
                <a href="send_login" style="color:#029789!important;">用已有账号登录</a>
            </div>
        </form>
    </div><!--row end-->
</div><!--container end-->

<script src="/js/layui/layui.all.js"></script>
<script>
    layui.use(['form', 'jquery', 'layer'], function () {
        //操作对象
        var form = layui.form;
        var $ = layui.jquery;
        //session过期时iframe子页面嵌套登录页面
        if (window != top)
            top.location.href = location.href;
        form.verify({
            username: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value == null || value == '') {
                    return '用户账号必填';
                }
            }
            , password: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value == null || value == '') {
                    return '密码必填';
                }
            }
        });
        //提交form表单
        form.on('submit(relogin)', function (data) {
            console.info(data.field)
            var field = data.field;
            //确认密码
            if(field.password !== field.repass){
                return layer.msg('两次密码输入不一致');
            }
            //是否同意用户协议
            if(!field.agreement){
                return layer.msg('你必须同意用户协议才能注册');
            }
            $.post("trackUser/relogin", data.field, function (data) {
                console.info("返回结果:--" + data)
                if (data == 'success') {
                    location.href = "send_login"
                } else {
                    layer.msg(data)
                }
            })
            return false;
        })
    })
</script>
</body>
</html>
